<template>
  <!--结清案件池-->
  <section class="page company-manage">
    <data-form :model="queryModel" :page="pageService" @handleResetForm="follFeedback" @onSearch="refreshData">
      <template slot="inputs">
        <el-form-item label="批次号" prop="outBatch">
          <el-input v-model="queryModel.outBatch"></el-input>
        </el-form-item>
        <el-form-item label="订单编号" prop="caseNumber">
          <el-input v-model="queryModel.caseNumber"></el-input>
        </el-form-item>
        <el-form-item label="客户姓名" prop="personalName">
          <el-input v-model="queryModel.personalName"></el-input>
        </el-form-item>
        <el-form-item label="手机号" prop="mobileNo">
          <el-input v-model="queryModel.mobileNo"></el-input>
        </el-form-item>
        <el-form-item label="身份证号" prop="idCard">
          <el-input v-model="queryModel.idCard  "></el-input>
        </el-form-item>
        <el-form-item label="地区" prop="area">
          <el-input v-model="queryModel.area"></el-input>
          <!-- <el-cascader v-model="queryModel.area" :options="$city.getCityData()" change-on-select
          clearable></el-cascader>-->
        </el-form-item>
        <el-form-item label="催收员" prop="currentCollector">
          <el-input v-model="queryModel.currentCollector"></el-input>
        </el-form-item>
        <el-form-item label="委外方" prop="outsName">
          <el-select clearable placeholder="请选择" v-model="queryModel.outsName">
            <el-option :key="item.id" :label="item.outsName" :value="item.id" v-for="item in outSourceList"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="案件金额" prop="caseMoney">
          <number-range :isInteger="true" v-model="queryModel.caseMoney"></number-range>
        </el-form-item>
        <el-form-item label="欠款金额" prop="outAmount">
          <number-range :isInteger="true" v-model="queryModel.outAmount"></number-range>
        </el-form-item>
        <el-form-item label="逾期期数" prop="overduePeriod">
          <el-select clearable placeholder="请选择" v-model="queryModel.overduePeriod">
            <el-option :key="index" :label="name" :value="code.replace(/M|\+/, '')" v-for="{index,name,code} in $dict.getDictData('OverduePeriodStatus')"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="逾期天数" prop="overdueDays">
          <number-range v-model="queryModel.overdueDays"></number-range>
        </el-form-item>
        <el-form-item label="行动代码" prop="followupBack">
          <el-select clearable placeholder="请选择" v-model="queryModel.followupBack">
            <el-option :key="index" :label="name" :value="code" v-for="{index,name,code} in $dict.getDictData('FollowupBack')"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="流转来源" prop="turnSource">
          <el-select clearable placeholder="请选择" v-model="queryModel.turnSource">
            <el-option :key="index" :label="name" :value="code" v-for="{index,name,code} in $dict.getDictData('TurnSource')"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品类型" prop="productCategory">
          <el-input v-model="queryModel.productCategory"></el-input>
        </el-form-item>
        <el-form-item label="产品名称" prop="productName">
          <el-input v-model="queryModel.productName"></el-input>
        </el-form-item>
        <el-form-item label="案件流入时间" prop="followInTime">
          <el-date-picker :editable="false" clearable placeholder="选择日期时间" type="daterange" v-model="queryModel.followInTime"></el-date-picker>
        </el-form-item>
        <el-form-item label="案件标签" prop="labelName">
          <get-label-name :formModel="queryModel" v-model="queryModel.labelName"></get-label-name>
        </el-form-item>
      </template>
    </data-form>
    <data-box :data="dataList" :page="pageService" :selectionList.sync="selectionList" @onPageChange="refreshData">
      <template slot="columns">
        <el-table-column :min-width="$helper.getColumnWidth(6)" label="订单编号">
          <template slot-scope="scope">
            <el-button @click="openExecutionPage(scope.row)" type="text">{{scope.row.caseNumber}}</el-button>
          </template>
        </el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="批次号" prop="outBatch"></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(3)" label="客户姓名" prop="personalName"></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="手机号" prop="mobileNo" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(7)" label="身份证号" prop="idCard" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="地区" prop="area" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="案件金额(元)" prop="caseMoney"></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="欠款金额(元)" prop="overdueAmount" show-overflow-tooltip></el-table-column>
        <el-table-column :formatter="row => $common.isNotValue(row.overduePeriod) ? '':`M${row.overduePeriod}`" :min-width="$helper.getColumnWidth(3)" label="逾期期数" prop="overduePeriod"></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="逾期天数" prop="overdueDays" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="产品类型" prop="productCategory" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(4)" label="产品名称" prop="productName" show-overflow-tooltip></el-table-column>
        <!-- <el-table-column prop="" label="顾客类型" :min-width="$helper.getColumnWidth(4)" show-overflow-tooltip>
        </el-table-column>-->
        <el-table-column :formatter="(row) => $filter.dictConvert(row.turnSource,'TurnSource')" :min-width="$helper.getColumnWidth(4)" label="流转来源" prop="turnSource" show-overflow-tooltip></el-table-column>
        <el-table-column :formatter="(row) => $filter.dateTimeFormat(row.followInTime)" :min-width="$helper.getColumnWidth(6)" label="案件流入时间" prop="followInTime"></el-table-column>
        <el-table-column :formatter="(row) => $filter.dictConvert(row.followupBack,'FollowupBack')" :min-width="$helper.getColumnWidth(4)" label="行动代码" prop="followupBack" show-overflow-tooltip></el-table-column>
        <el-table-column :min-width="$helper.getColumnWidth(10)" label="案件标签" prop="labelName"></el-table-column>
      </template>
    </data-box>
  </section>
</template>

<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import { Dependencies, Layout, Auth } from "~/core/decorator";
import { OutsourceSettleManageService } from "~/services/domain-service/outsource-settle-manage.service";
import { PageService } from "~/utils/page.service";
import NumberRange from "~/components/common/number-range.vue";
import { CityService } from "~/utils/city.service";
import { SortService } from "~/utils/sort.service";
import { CASE_CHANNEL, MENU_CHANNEL } from "~/config/enum.config";
import { namespace, State } from "vuex-class";
import GetLabelName from "~/components/labeling-strategy/get-label-name.vue";

@Auth(1005)
@Layout("workspace")
@Component({
  components: {
    GetLabelName,
    NumberRange
  }
})
export default class SellteManageIndex extends Vue {
  @Dependencies(OutsourceSettleManageService)
  private OutsourceSettleManageService: OutsourceSettleManageService;
  @Dependencies(PageService)
  private pageService: PageService;
  @Dependencies(SortService)
  private sortService: SortService;
  @State
  private outSourceList;

  private selectionList: any[] = [];
  private proinviceList: any[] = []; // 省
  private cityList: any[] = []; //市
  // form 查询表单参数
  private queryModel: any = {
    outBatch: "",
    caseNumber: "",
    personalName: "",
    mobileNo: "",
    idCard: "",
    localAddress: "",
    currentCollector: "",
    overduePeriod: "",
    turnSource: "",
    FollowupBack: "",
    productCategory: "",
    productName: "",
    area: "",
    followupBack: "",
    outAmount: {
      max: "",
      min: ""
    },
    caseMoney: { min: "", max: "" },
    overdueDays: {
      max: "",
      min: ""
    },
    followInTime: [], //案件流入时间
    outsName: "",
    labelName: []
  };
  private dataList: any[] = [];

  private mounted() {
    this.refreshData();
    this.getProvinces();
  }

  //获取省数据
  private getProvinces() {
    this.proinviceList = CityService.getCityData({ level: 1 });
  }

  //获取市
  private getCitys(provinceId) {
    if (this.queryModel.cityCode) {
      this.queryModel.cityCode = "";
    }
    this.cityList = this.$city.getCityData({ level: 1, id: provinceId }); // 城市列表
  }

  /**
   * 查询列表
   */
  private refreshData() {
    this.OutsourceSettleManageService.getCaseSettlePoolPageList(
      this.queryModel,
      this.pageService,
      this.sortService
    ).subscribe(data => {
      this.dataList = data;
    });
  }

  /**
   * 进入查看执行页
   */
  private openExecutionPage(row) {
    this.$router.openCaseDetail(row.id, {
      menuChannel: MENU_CHANNEL.Outsource_settle,
      hiddenCaseList: true,
      hiddenAction: true
    });
  }

  /**
   * 重置numberRange
   */
  private follFeedback() {
    this.queryModel.outAmount = { min: "", max: "" };
    this.queryModel.overdueDays = { min: "", max: "" };
    this.queryModel.proinviceCode = "";
    this.queryModel.cityCode = "";
    this.queryModel.caseMoney = { min: "", max: "" };
  }
}
</script>

<style lang="less">
</style>


